<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        //创建类
        class Star {
            //构造函数 接受实参，返回对象
            constructor(uname) {
                this.uname = uname;
            }
            //添加类中共有的方法
            sing(song) {
                console.log(this.uname + '会唱' + song);
            }
        }

        //创建对象
        var ldh = new Star('刘德华');
        console.log(ldh.uname);
        ldh.sing('冰雨');

    </script>
</body>

</html>